{% set pypi_name = 'python-keystoneclient' %}
{% set upstream_version = upstream_version('4.2.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('python-keystoneclient') }}
Summary:        Client library for OpenStack Identity API
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openssl
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('keystoneauth1') }}
BuildRequires:  {{ py3('lxml') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testresources') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildArch:      noarch

%description
Client library for interacting with Openstack Identity API.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Client library for OpenStack Identity API
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}

%description -n {{ py2name(py_versions='py3') }}
Client library for interacting with Openstack Identity API.

%package -n python-keystoneclient-doc
Summary:        Documentation for OpenStack Identity API Client
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-keystoneclient-doc
Documentation for the client library for interacting with Openstack
Identity API.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup
# disable intersphinx - no network access during build
echo "intersphinx_mapping = {}" >> doc/source/conf.py

%build
%{py3_build}

# Build HTML docs and man page
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%doc README.rst
%license LICENSE
%{python3_sitelib}/keystoneclient
%{python3_sitelib}/*.egg-info

%files -n python-keystoneclient-doc
%doc doc/build/html
%license LICENSE

%changelog
